﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Data;
using CsvHelperPlus;


namespace DataSource
{
    static public class DateUtils
    {
        static string tradeDateFile;
        static List<string> dateList;
        static DateUtils()
        {
            tradeDateFile = @"X:\data\tradingDate\tradingDate.csv";
            dateList = new List<string>();
            LoadFile();
        }

        static private void LoadFile()
        {
            StreamReader sr = new StreamReader(tradeDateFile, Encoding.Default);
            string line;
            while (!sr.EndOfStream)
            {
                line = sr.ReadLine();
                dateList.Add(line);
            }
        }

        static public string GetLastTradeDate(string date)
        {
            int i = dateList.IndexOf(date);
            return dateList[i - 1];
        }

        static public string ToString(DateTime dt)
        {
            return dt.ToString("yyyyMMdd");
        }

    }
}
